package com.yuyou.fn.tms.controller;

import com.yuyou.fn.tms.service.IDataSyncService;
import com.yuyou.fn.tms.util.Signs;
import com.yuyou.fn.tms.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.validation.Valid;

@Controller
@RequestMapping("/api/data/sync")
@Api(tags = "数据同步")
public class DataSyncController extends Binder{

    private final static Logger log  = LoggerFactory.getLogger(DataSyncController.class);

    @Value("${tms.sign.key}")
    private String signKey ;

    @Resource
    private IDataSyncService dataSyncService;


    @ApiOperation(value = "同步班级" )
    @RequestMapping( value = "/getZyClass" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsCourseClass>> getZyClass(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsCourseClass> result =  dataSyncService.queryTmsCourseClass(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "根据学位变更时间查询学位接口" )
    @RequestMapping( value = "/getSurplusQuotaByClaQuotaModifyTime" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsClassDegree>> getSurplusQuotaByClaQuotaModifyTime(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsClassDegree> result =  dataSyncService.queryTmsClassDegree(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "排课表同步列表" )
    @RequestMapping( value = "/getCurriculumList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsClassLecture>> getCurriculumList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsClassLecture> result =  dataSyncService.queryTmsClassLecture(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "获取省份列表接口" )
    @RequestMapping( value = "/getProvinceList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsProvince>> getProvinceList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsProvince> result =  dataSyncService.queryTmsProvince(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "获取城市列表接口" )
    @RequestMapping( value = "/getCityList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsCity>> getCityList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsCity> result =  dataSyncService.queryTmsCity(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "获取地区列表接口" )
    @RequestMapping( value = "/getAreaList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsDistrict>> getAreaList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsDistrict> result =  dataSyncService.queryTmsDistrict(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "获取校区列表接口" )
    @RequestMapping( value = "/getDeptList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsCampus>> getDeptList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsCampus> result =  dataSyncService.queryTmsCampus(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "获取年级列表接口" )
    @RequestMapping( value = "/getGradeList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsGrade>> getGradeList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsGrade> result =  dataSyncService.queryTmsGrade(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "获取层级列表接口" )
    @RequestMapping( value = "/getGradationList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsLevel>> getGradationList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsLevel> result =  dataSyncService.queryTmsLevel(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "获取产品类别列表接口" )
    @RequestMapping( value = "/getProductTypeList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsProduct>> getProductTypeList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsProduct> result =  dataSyncService.queryTmsProduct(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "获取学科列表接口" )
    @RequestMapping( value = "/getSubjectList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsSubject>> getSubjectList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsSubject> result =  dataSyncService.queryTmsSubject(requestParam);
        return ResponseResult.success(result) ;
    }


    @ApiOperation(value = "课程模板同步接口" )
    @RequestMapping( value = "/getCourseTempletList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsCourseTemplate>> getCourseTempletList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsCourseTemplate> result =  dataSyncService.queryTmsCourseTemplate(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "学生同步接口" )
    @RequestMapping( value = "/getStudentList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsStudent>> getStudentList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsStudent> result =  dataSyncService.queryTmsStudent(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "生源学校同步接口" )
    @RequestMapping( value = "/getFeederSchoolsList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsSchool>> getFeederSchoolsList(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsSchool> result =  dataSyncService.queryTmsSchool(requestParam);
        return ResponseResult.success(result) ;
    }
    

    @ApiOperation(value = "收费段次设置同步接口" )
    @RequestMapping( value = "/getPaySegment" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsChargeSetting>> findChargeSetting(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsChargeSetting> result =  dataSyncService.queryTmsChargeSetting(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "教师同步接口" )
    @RequestMapping( value = "/getTeacherList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsTeacher>> findTeacher(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsTeacher> result =  dataSyncService.queryTmsTeacher(requestParam);
        return ResponseResult.success(result);
    }

    @ApiOperation(value = "班级老师关系同步" )
    @RequestMapping( value = "/getZyclassTeacherList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsClassTeacher>> findClassTeacher(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsClassTeacher> result =  dataSyncService.queryTmsClassTeacher(requestParam);
        return ResponseResult.success(result) ;
    }

    @ApiOperation(value = "报名同步接口" )
    @RequestMapping( value = "/getRegList" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<PageQueryResult<TmsReg>> findReg(@Valid @RequestBody PageRequestParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        PageQueryResult<TmsReg> result =  dataSyncService.queryTmsReg(requestParam);
        return ResponseResult.success(result) ;
    }


}
